Skip to content

fix: handle invalid JSON in semgrep parser and add unit tests#1741

Open
vedasingh00-rgb wants to merge 2 commits into
utksh1:mainfrom
vedasingh00-rgb:fix/semgrep-parser-tests
Open

fix: handle invalid JSON in semgrep parser and add unit tests#1741
vedasingh00-rgb wants to merge 2 commits into
utksh1:mainfrom
vedasingh00-rgb:fix/semgrep-parser-tests

Conversation

@vedasingh00-rgb

Copy link
Copy Markdown
Contributor

Description

Fixed the semgrep_scanner parser to handle invalid JSON gracefully instead of silently ignoring errors. Added unit tests to verify all three scenarios — valid JSON, invalid JSON, and mixed stdout output.

Related Issues

#1421

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Added 3 unit tests in testing/test_semgrep_parser.py and ran them using pytest:
test_valid_json — verifies valid Semgrep JSON is parsed correctly
test_invalid_json — verifies invalid JSON does not crash the parser
test_mixed_stdout — verifies mixed stdout is handled gracefully

image

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

@utksh1 utksh1 added the gssoc:approved Admin validation: approved for GSSoC scoring label Jul 9, 2026

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The semgrep JSON-handling fix and tests look good, but the branch has merge conflicts. Please rebase on latest main and push again — should be straightforward to land after that.

@utksh1 utksh1 added level:intermediate 35 pts difficulty label for moderate contributor PRs type:bug Bug fix work category bonus label area:plugins Scanner plugin metadata, schemas, or plugin runtime work type:testing Testing work category bonus label labels Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:plugins Scanner plugin metadata, schemas, or plugin runtime work gssoc:approved Admin validation: approved for GSSoC scoring level:intermediate 35 pts difficulty label for moderate contributor PRs type:bug Bug fix work category bonus label type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants